package com.xbj.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xbj.model.News;
import com.xbj.model.User;
import com.xbj.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by JzzZ
 * Date: 2018\7\9 0009
 * Time: 15:39
 * Project: News2.0
 * File description:
 */
@Controller
public class NewsController {

    @Autowired
    NewsService newsService;

    @RequestMapping("/newsList")
    public String newsList(@RequestParam(required=true,defaultValue="1") Integer page
            , HttpServletRequest request, Model model){

        PageHelper.startPage(page, 10);
        List<News> newsList = newsService.newsList();
        PageInfo<News> p=new PageInfo<News>(newsList);
        model.addAttribute("page", p);
        model.addAttribute("newsList",newsList);
        return "admin/jsp/right";
    }

}
